package com.cn.zpark;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @PackageName: com.cn.zpark
 * @ClassName: MyServletDemo01
 * @Description:
 * @author: RZS
 * @date: 2022/4/6  16:08
 */
@WebServlet("/mys1.do")
public class MyServletDemo01 extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // 设置响应类型
        resp.setContentType("text/html;charset=utf-8");
        // 创建写出流
        PrintWriter w = resp.getWriter();
        w.println("<h1>使用注解开发Servlet</h1>");

        // 关闭资源
        w.close();
    }
}
